package com.bdqn.ch01.controller;

import com.bdqn.ch01.entity.User;
import com.bdqn.ch01.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class HelloController {

    //@Resource   首先按照名称
    //@Autowired  首先按照类型  @Qualifier
    @Resource
    UserService userServiceImp;

/*    @Value("${com.bdqn.name}")
    private String name;
    @Value("${com.bdqn.email}")
    private String email;*/

    @Resource
    User user;

    @RequestMapping(value = "hello")
    public String hello() {
        return "hello T294 git";
    }

    @RequestMapping(value = "getname")
    public String getName(String id) {
        return user.getName() + "," + user.getEmail() + "," + id;
    }

}
